package com.example.chang.law_doc.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.chang.law_doc.R;
import com.wyt.searchbox.SearchFragment;
import com.wyt.searchbox.custom.IOnSearchClickListener;

/**
 * Created by chang on 2018/4/8.
 * 项目描述：
 */

public class ExplainActivity extends AppCompatActivity implements View.OnClickListener {
    private TextView tv_text;
    private TextView ex_title;
    private TextView ex_content;
    private EditText ed_search;
    private ImageView IV_back;
    private LinearLayout L1;
    private LinearLayout L2;
    private TextView text_Liner;
    private SearchFragment searchFragment;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_explain);
        ActionBar actionBar=getSupportActionBar();
        if (actionBar!=null){
            actionBar.hide();
        }
        initView();
    }

    private void initView() {
        searchFragment = SearchFragment.newInstance();
        ed_search = (EditText) findViewById(R.id.et_search);
        text_Liner= (TextView) findViewById(R.id.text_Liner);
        ex_title= (TextView) findViewById(R.id.ex_title);
        ex_content= (TextView) findViewById(R.id.ex_content);

        ed_search.setOnClickListener(this);
        L1=(LinearLayout)findViewById(R.id.search_1);
        L2=(LinearLayout)findViewById(R.id.search_2);
        L1.setVisibility(View.VISIBLE);
        L2.setVisibility(View.GONE);

        IV_back= (ImageView) findViewById(R.id.IV_back);
        IV_back.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.IV_back:
                finish();
                break;
            case R.id.et_search:
                searchFragment = SearchFragment.newInstance();
                searchFragment.setOnSearchClickListener(new IOnSearchClickListener() {
                    @Override
                    public void OnSearchClick(String keyword) {
                        ed_search.setText(keyword);
                        String string="关键词：  "+keyword;
                        text_Liner.setText(string);
                        L1.setVisibility(View.GONE);
                        L2.setVisibility(View.VISIBLE);
                        String str="索赔";
                        if (str.equals(keyword))
                        {
                            ex_title.setText("索赔:");
                            ex_content.setText("指在本合同履行过程中，对于并非自己的过错，而是应由对方承担责任的情况造成的实际损失，向对方提出经济补偿和（或）工期延长的要求。");
                        }

                    }
                });
                searchFragment.show(getSupportFragmentManager(), SearchFragment.TAG);
                break;
        }

    }
}
